package com.gelsanalyzer.application;

import java.awt.*;
import java.beans.*;

import javax.swing.*;

import org.apache.log4j.*;

import com.gelsanalyzer.mvc.controller.*;
import com.gelsanalyzer.mvc.view.*;
import com.gelsanalyzer.ui.swing.*;

public class StudentAppFrameView extends JFrame implements IView {
    private static final Logger log = Logger.getLogger(StudentAppFrameView.class);
    
    // Create a Tabbed pane and a panel to put it in...
    private JTabbedPane tabbedPane = new JTabbedPane();
    private JPanel basePanel = new JPanel();

    //@SuppressWarnings(value = { "unchecked" })
    public StudentAppFrameView() {
        //setResizable(false);
        setPreferredSize(new Dimension(750,750));
        tabbedPane.setPreferredSize(new Dimension(500, 700));
    }


    /**
     * Method adds the child views that this Frame contains. Called from this
     * Frame's controller
     * 
     * @param courseEntryView
     * @param recordAdjView
     * @param recordDispView
     * @param courseSelectorView
     */
    public void addComponents(Component courseEntryView,
                              IView recordAdjView,
                              Component reportViewerView,
                              Component courseSelectorView, Component courseOptimizerView) {
        basePanel.setLayout(new BorderLayout());
        this.setContentPane(basePanel);
        this.setTitle("GELS Analyzer");
        
        tabbedPane.addTab("Selected Courses", courseEntryView);
        tabbedPane.addTab("Optimized Courses", null, courseOptimizerView, 
            "Click on this tab to view a list of your completed GELs so far.");
        tabbedPane.addTab("Course and Goal Area Listings", null, 
            reportViewerView, "Click on this tab to view and print reports " +
            		"of Courses and Goal Areas.");
        // tabbedCoursePane.addTab("Applied Areas", recordAdjView);
        // tabbedCoursePane.addTab("Printable View", recordDispView);
        
        basePanel.add(tabbedPane, BorderLayout.EAST);
        basePanel.add(courseSelectorView, BorderLayout.WEST);

        this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
        this.addWindowListener(new CourseMgmtWindowListener(this));
    }


    
    public void modelPropertyChange(PropertyChangeEvent event) {
        log.info("modelPropertyChange(PropertyChangeEvent "+event);
        if (event.getPropertyName().equals(IController.APP_GENERIC_COMMAND)) {
            // Could update the GUI or anything else...
        }
    }
    
    

}
